package com.ppl.server.boot.config;

import com.google.inject.BindingAnnotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Marks a field as injected from configuration. It is possible to annotate a
 * class also, in which case, it will allow to scope field configuration. For
 * example :
 * 
 * <pre>
 * <code>
 * @Config("very.long.path")
 * class SomeBean {
 *   // The full path of this value is "very.long.path.something-shorter"
 *   @Config("something-shorter")
 *   int value;
 * }
 * </code>
 * </pre>
 * 
 * A field value can also be an annotated POJO, it will created and all its
 * annotated fields will be injected using the field path as a parent scope, for
 * example :
 * 
 * <pre>
 * <code> 
 * class SomeBean {
 *   @Config("pojo")
 *   SomePojo pojo;
 * }
 * 
 * class SomePojo {
 *   // The full path of this value would be "pojo.value", when injected in SomeBean
 *   @Config("value")
 *   int value;
 * }
 * </code>
 * </pre>
 * 
 * <p>
 * This annotation should not be used in conjunction with {@link com.google.inject.Inject}.
 * 
 * @author Nicolas Berthet
 * @since May 3, 2012 10:19:03 AM
 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE, ElementType.FIELD })
@BindingAnnotation
public @interface Config {

	/**
	 * The key in the configuration that holds the value for the annotated
	 * member.
	 * 
	 * @return
	 */
	String value();
	
	boolean optional() default false;
	
	String description() default "";
}
